<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>全部分类</title>
    <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    <style media="screen">
        body {
            /*background:;*/
            /*opacity: 0.4;*/
            background: rgba(0, 0, 0, 0.2);
            margin: 0;
            padding: 0;
            position: absolute;
            height: 100%;
        }

        .wrap {
            width: 100%;
            height: 100%;
            /*overflow: hidden;*/
        }

        .wrap_inner {
            width: 100%;
            height: 100%;
            position: relative;
        }

        .content {
            width: 100%;
            padding: 10px 15px;
            /*height: 260px;*/
            background: #fff;
            position: absolute;
            top: 0;
            z-index: 99;
            border-bottom-left-radius: 6px;
            border-bottom-right-radius: 6px;
            padding-bottom: 10px;
        }

        .title {
            width: 100%;
            display: flex;
            justify-content: space-between;
            /*padding-top: 10px;*/
        }

        .title span:first-child {
            width: auto;
            height: 22px;
            line-height: 22px;
            color: #333333;
            font-size: 14px;
        }

        .title span:last-child {
            width: 22px;
            height: 22px;
        }

        .title span:last-child img {
            display: block;
            width: 100%;
            height: 100%;
        }

        .content ul {
            width: 100%;
            /*padding: 0 15px;*/
        }

        .content ul li {
            width: 25%;
            margin-top: 20px;
            float: left;
            overflow: hidden;
        }

        .content ul li span {
            display: block;
        }

        .content ul li span:nth-child(1) {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            /*background-color: red;*/
            margin: 0 auto;
        }

        .content ul li span:nth-child(1) img {
            width: 100%;
            height: 100%;
            display: block;
        }

        .content ul li span:nth-child(2) {
            width: auto;
            height: 15px;
            line-height: 15px;
            font-size: 13px;
            font-family: PingFang SC;
            font-weight: 400;
            color: #333333;
            margin-top: 5px;
            text-align: center;
        }

        [v-cloak] {
            display: none!important;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak>
        <div class="wrap">
            <div class="wrap_inner">
                <div class="content">
                    <div class="title">
                        <span>选择分类</span>
                        <span @click="closeF()"><img src="../../image/arrow_top.png" alt=""></span>
                    </div>
                    <ul>
                        <li v-for='(item,index) in navList' @click='selectIndexCategory(index)'>
                            <span><img :src="item.cpic" alt="" v-cache-src="item.cpic" alt=""></span>
                            <span>{{item.cname}}</span>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/vue.js"></script>
<script type="text/javascript" src="../../script/cling.js"></script>
<script type="text/javascript">
    /**
     * [注册一个全局自定义指令 `V-   cache-src`]
     * @param  {[type]} el      [需要图片缓存的元素]
     * @param  {[type]} binding [服务器图片对象数据]
     * @return {[type]}         [服务器图片地址]
     */
    Vue.directive('cache-src', function(el, binding) {
        if (binding) {
            setTimeout(function() {
                api.imageCache({
                    url: binding.value,
                    thumbnail: false
                }, function(ret, err) {
                    if (ret && ret.status) {
                        el.setAttribute("src", ret.url);
                    }
                });
            }, 100);
        }
    });
    apiready = function() {
        vm.getIndexCateGory()
    }
    var vm = new Vue({
        el: '#app',
        data: {
            navList: []
        },
        methods: {
            getIndexCateGory: function() {
                api.ajax({
                    url: cl.apiServer + 'category/getCategoryList',
                    method: 'post',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8',
                        token: ''
                    },
                    data: {
                        body: {
                            parentId: 0,
                            ctype: 1,
                            version:cl.deviceInfo().appVersion,
                            mobileInfo:cl.systemType()
                        }
                    }
                }, function(ret, err) {
                    if (ret) {
                        if (ret.code == 0) {
                            vm.navList = ret.data;
                        }
                    }
                })
            },
            selectIndexCategory: function(index) {
                api.sendEvent({
                    name: 'sendIdx',
                    extra: {
                        index: index
                    }
                });
                cl.closeFrame({
                    name: 'inxcategory_frame'
                })

            },
            closeF: function() {
              api.removePrefs({
                  key: 'isOpenlayer'
              });
                cl.closeFrame({
                    name: 'inxcategory_frame'
                })
            }
        }
    });
</script>

</html>
